home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / doc / plplot-fmt < prev    next >
Encoding:
Text File  |  1994-05-24  |  9.7 KB  |  277 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; 
  3. ;;; Elisp functions for use with the PLplot latexinfo document. 
  4. ;;; written by Maurice J. LeBrun (mjl@dino.ph.utexas.edu)
  5. ;;; Version:         $Revision: 1.3 $
  6. ;;; Last Modified:   $Date: 1994/05/23 22:04:27 $
  7. ;;;
  8. ;;; These functions are the elisp counterparts to the macros and/or
  9. ;;; environments in plplot.sty.  Both must be present, since the latexinfo
  10. ;;; file is processed by both emacs and latex.
  11. ;;;
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13.  
  14. (require 'latexinfo)
  15.  
  16. ;; Here we register the recognized keywords.
  17. ;; Their handlers are defined below.
  18.  
  19. (put 'message 'latexinfo-format 'latexinfo-message)
  20.  
  21. (put 'name 'latexinfo-format 'plplot-format-bname)
  22. (put 'bname 'latexinfo-format 'plplot-format-bname)
  23. (put 'bnameC 'latexinfo-format 'plplot-format-bnameC)
  24. (put 'bnameF 'latexinfo-format 'plplot-format-bnameF)
  25. (put 'bnameCF 'latexinfo-format 'plplot-format-bnameCF)
  26.  
  27. (put 'namend 'latexinfo-format 'plplot-format-namend)
  28. (put 'descr 'latexinfo-format 'plplot-format-descr)
  29. (put 'argu 'latexinfo-format 'plplot-format-argu)
  30. (put 'rou 'latexinfo-format 'plplot-format-rou)
  31.  
  32. ;; These are null.
  33.  
  34. (put 'addcontentsline 'latexinfo-format 'plplot-format-null)
  35. (put 'label 'latexinfo-format 'plplot-format-null)
  36.  
  37. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  38. ;; latexinfo-message
  39. ;;
  40. ;; Handle the \message{string} macro.
  41. ;; Handy for sending messages to the user (for debugging or whatever).
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43.  
  44. (defun latexinfo-message ()
  45.   (let ((args (latexinfo-format-parse-multiargs)))
  46.     (latexinfo-discard-command)
  47.     (message (nth 0 args))
  48.     ))
  49.  
  50. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  51. ;; latexinfo-format-parse-multiargs
  52. ;;
  53. ;; This function parses a number of arguments in LaTeX fashion.
  54. ;; E.g. \foo{a}{b}{c}
  55. ;; It's up to the caller to determine what to do with them.
  56. ;; Returns in arguments ARE significant.
  57. ;;
  58. ;; Limitations: 
  59. ;;
  60. ;; - Only two levels of brace nesting inside arguments is permitted.  
  61. ;;   Typically the deepest you will need is one level anyway, so this
  62. ;;   isn't likely to be a problem.
  63. ;;
  64. ;; - The open brace on multi-args must IMMEDIATELY follow the close brace
  65. ;;   from the previous arg.  You can skip to the next line after that
  66. ;;   (it helps readability with long args) without it affecting the
  67. ;;   output, as long as there are no trailing blanks after the end brace.
  68. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  69.  
  70. (defun latexinfo-format-parse-multiargs ()
  71.   (let ((start (1- (point)))
  72.     next beg end
  73.     args)
  74.     (search-forward "{")
  75.     (forward-char -1)
  76.     (while (= (following-char) ?\{)
  77.       (forward-char 1)
  78.       (skip-chars-forward " \t\n")
  79.       (setq beg (point))
  80.  
  81. ; Here I check for two extra levels of brace nesting.
  82.  
  83.       (re-search-forward "[{}]")
  84.       (while (= (preceding-char) ?\{)
  85.     (re-search-forward "[{}]")
  86.     (while (= (preceding-char) ?\{)
  87.       (re-search-forward "[{}]")
  88.       (if (= (preceding-char) ?\{)
  89.           (progn
  90.         (message "Too many nested braces in argument, hoser")
  91.         (re-search-forward "}")
  92.         ))
  93.       (re-search-forward "[{}]")
  94.       )
  95.     (re-search-forward "[{}]")
  96.     )
  97.  
  98.       (setq next (point))
  99.       (forward-char -1)
  100.       (skip-chars-backward " \t\n")
  101.       (setq end (point))
  102.       (setq args (cons (if (> end beg) (buffer-substring beg end))
  103.                args))
  104.       (goto-char next))
  105.     (if (eolp) (forward-char 1))
  106.     (setq latexinfo-command-end (point))
  107.     (nreverse args)))
  108.  
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. ;; plplot-format-bname
  111. ;;
  112. ;; Handle the \bname{arg} and \name{arg} macros.
  113. ;; `arg' is the name of the function and its arguments.
  114. ;;
  115. ;; This is used for setting off a function specification.  In the printed
  116. ;; document, a box is drawn around the function (\bname only; \name just
  117. ;; causes it to be offset).  Note: I tried adding indentation but there's
  118. ;; no easy way -- it'd require massive elisp hacking.
  119. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  120.  
  121. (defun plplot-format-bname ()
  122.   (let ((args (latexinfo-format-parse-multiargs)))
  123.     (latexinfo-discard-command)
  124.     (insert
  125. "--------------------------------------------------------------------------\n")
  126.     (insert (nth 0 args) "\n")
  127.     (insert
  128. "--------------------------------------------------------------------------\n")
  129.     (goto-char latexinfo-command-start)
  130.     ))
  131.  
  132. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  133. ;; plplot-format-bnameC
  134. ;;
  135. ;; Handle the \bnameC{arg} macro.
  136. ;; `arg' is the name of the function and its arguments.
  137. ;;
  138. ;; Like \bname but designates it for use from C only.
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140.  
  141. (defun plplot-format-bnameC ()
  142.   (let ((args (latexinfo-format-parse-multiargs)))
  143.     (latexinfo-discard-command)
  144.     (insert
  145. "--------------------------------------------------------------------------\n")
  146.     (insert (nth 0 args) "      (C)\n")
  147.     (insert
  148. "--------------------------------------------------------------------------\n")
  149.     (goto-char latexinfo-command-start)
  150.     ))
  151.  
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  153. ;; plplot-format-bnameF
  154. ;;
  155. ;; Handle the \bnameF{arg} macro.
  156. ;; `arg' is the name of the function and its arguments.
  157. ;;
  158. ;; Like \bname but designates it for use from Fortran only.
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160.  
  161. (defun plplot-format-bnameF ()
  162.   (let ((args (latexinfo-format-parse-multiargs)))
  163.     (latexinfo-discard-command)
  164.     (insert
  165. "--------------------------------------------------------------------------\n")
  166.     (insert (nth 0 args) "      (Fortran)\n")
  167.     (insert
  168. "--------------------------------------------------------------------------\n")
  169.     (goto-char latexinfo-command-start)
  170.     ))
  171.  
  172. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  173. ;; plplot-format-bnameCF
  174. ;;
  175. ;; Handle the \bnameCF{arg1}{arg2}{arg3}{arg4} macro.
  176. ;; `arg1' and `arg2' is the specification for use from C.
  177. ;; `arg3' and `arg4' is the specification for use from Fortran.
  178. ;;
  179. ;; Like \bname but displays 2 specifications: one for C and one for Fortran.
  180. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  181.  
  182. (defun plplot-format-bnameCF ()
  183.   (let ((args (latexinfo-format-parse-multiargs)))
  184.     (latexinfo-discard-command)
  185.     (insert
  186. "--------------------------------------------------------------------------\n")
  187.     (insert (nth 0 args) (nth 1 args) "\n")
  188.     (insert (nth 2 args) (nth 3 args) "\n")
  189.     (insert
  190. "--------------------------------------------------------------------------\n")
  191.     (goto-char latexinfo-command-start)
  192.     ))
  193.  
  194. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  195. ;; plplot-format-descr
  196. ;;
  197. ;; Handle the \descr{arg} macro.
  198. ;; `arg' is the description of a function.
  199. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  200.  
  201. (defun plplot-format-descr ()
  202.   (let ((args (latexinfo-format-parse-multiargs)))
  203.     (latexinfo-discard-command)
  204.     (insert (nth 0 args))
  205.     (insert "\\refill\n")
  206.     (goto-char latexinfo-command-start)
  207.     ))
  208.  
  209. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  210. ;; plplot-format-rou
  211. ;;
  212. ;; Handle the \rou{arg} macro.
  213. ;; `arg' is the name of the function.
  214. ;;
  215. ;; This is used for referencing a function for the first time.  It uses a
  216. ;; tt font (in the printed doc) and refers the reader to its location in
  217. ;; the API section.  In the info document, a hot link is set up for this.
  218. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  219.  
  220. (defun plplot-format-rou ()
  221.   (let ((args (latexinfo-format-parse-multiargs)))
  222.     (latexinfo-discard-command)
  223.     (insert "\\code{" (nth 0 args) "}")
  224.     (insert " (\\pxref{" (nth 0 args) "})")
  225.     (goto-char latexinfo-command-start)
  226.     ))
  227.  
  228. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  229. ;; plplot-format-namend
  230. ;;
  231. ;; Handle the \namend macro.
  232. ;;
  233. ;; Just a nice way to terminate a function specification.
  234. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  235.  
  236. (defun plplot-format-namend ()
  237.   (latexinfo-discard-command)
  238.   (insert
  239. "--------------------------------------------------------------------------\n")
  240.   )
  241.  
  242. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  243. ;; plplot-format-argu
  244. ;;
  245. ;; Handle the \argu{arg1}{arg2} macro.
  246. ;; `arg1' is the name of the argument, its type, and input/output status.
  247. ;; `arg2' is a description of its effects.
  248. ;;
  249. ;; This is used for setting off the specification and explanation of
  250. ;; a function argument(s).  The explanation can be as long as you like,
  251. ;; even spanning multiple paragraphs or including enumerated lists.
  252. ;; Because of the trailing `\refill', be very careful that the last right
  253. ;; brace be the very last item on the line (no trailing spaces).
  254. ;; Otherwise some spurious blank lines are sometimes created.
  255. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  256.  
  257. (defun plplot-format-argu ()
  258.   (let ((args (latexinfo-format-parse-multiargs)))
  259.     (latexinfo-discard-command)
  260.     (insert (nth 0 args) ":\n\n")
  261.     (insert (nth 1 args))
  262.     (insert "\\refill\n")
  263.     (goto-char latexinfo-command-start)
  264.     ))
  265.  
  266. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  267. ;; plplot-format-null
  268. ;;
  269. ;; Handle a variety of constructs that do nothing on the info side.
  270. ;; Just a null function to satisfy the latex side.
  271. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  272.  
  273. (defun plplot-format-null ()
  274.   (let ((args (latexinfo-format-parse-multiargs)))
  275.     (latexinfo-discard-command)
  276.     ))
  277.